<template>
  <div class="admin-home-page">
    <h2 class="admin-title">管理员个人信息</h2>
    <el-card class="admin-info-card">
      <div class="info-row">
        <el-icon><HomeFilled /></el-icon>
        <span>项目名：选题管理系统</span>
      </div>
      <div class="info-row">
        <el-icon><User /></el-icon>
        <span>开发人员：工科大计应24级学生</span>
      </div>
      <div class="info-row">
        <el-icon><Location /></el-icon>
        <span>山西工程科技职业大学</span>
      </div>
      <div class="info-row">
        <el-icon><CloseBold /></el-icon>
        <span>仅供学习，禁止抄袭</span>
      </div>
    </el-card>
    <el-button type="danger" class="logout-btn" @click="onLogout">logout</el-button>
    <el-form :model="profile" label-width="80px" style="max-width: 400px; margin-top: 20px;">
      <el-form-item label="用户名">
        <el-input v-model="profile.username" disabled />
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="profile.name" />
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="profile.email" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveProfile">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { HomeFilled, User, Location, Message, CloseBold } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
import { ref } from 'vue'

const router = useRouter()
const profile = ref({
  username: 'admin',
  name: '管理员',
  email: 'admin@example.com'
})

const onLogout = () => {
  ElMessage.success('已退出登录')
  router.push('/login')
}

function saveProfile() {
  // TODO: 调用后端接口保存
  ElMessage.success('保存成功')
}
</script>

<style scoped>
.admin-home-page {
  padding: 40px 0 0 40px;
}
.admin-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 24px;
}
.admin-info-card {
  width: 400px;
  margin-bottom: 32px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.06);
}
.info-row {
  display: flex;
  align-items: center;
  font-size: 16px;
  margin-bottom: 12px;
  color: #333;
}
.info-row .el-icon {
  margin-right: 10px;
  font-size: 18px;
}
.logout-btn {
  background: #ff7b7b;
  border: none;
  color: #fff;
  font-size: 16px;
  border-radius: 20px;
  padding: 8px 32px;
  margin-top: 10px;
}
.logout-btn:hover {
  background: #ff4d4f;
  color: #fff;
}
</style>
